﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KL.Store.Core.Domain;
using TN.Data;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using KL.Store.Core;
using System.Web;
using System.Web.Caching;

namespace KL.Store.Data
{
    public class dbRefs
    {
        #region Get Ref1

        public static string GetRef1(int RefId)
        {
            try
            {
                var cacheKey = "GetRef1" + RefId;
                if (HttpRuntime.Cache[cacheKey] != null)
                {
                    return HttpRuntime.Cache[cacheKey] as string;

                }
                HttpRuntime.Cache.Add(cacheKey, Ref1L.FirstOrDefault(o => o.id == RefId).yanit, null, DateTime.UtcNow.AddDays(1), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
                return Ref1L.FirstOrDefault(o => o.id == RefId).yanit;
            }
            catch
            {
                Logger.Write("Reference2 Not Found, RefId = " + RefId.ToString(), "Exception");
                return null;
            }
        }

        #endregion

        #region Get Ref1List

        public static IList<Ref1> Ref1List()
        {
            IList<Ref1> RefList = new List<Ref1>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Ref1_All", RefList);
            return RefList;
        }

        #endregion

        #region Get Ref2

        public static DateTime GetRef2(int RefId)
        {
            try
            {
                return Ref2L.Where(o => o.id == RefId).FirstOrDefault().yanit;
            }
            catch
            {
                Logger.Write("Reference2 Not Found, RefId = " + RefId.ToString(), "Exception");
                return Convert.ToDateTime(0);
            }
        }

        #endregion

        #region Get Ref2List

        public static IList<Ref2> Ref2List()
        {
            IList<Ref2> RefList = new List<Ref2>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Ref2_All", RefList);
            return RefList;
        }

        #endregion

        #region Get Ref3

        public static decimal GetRef3(int RefId)
        {
            try
            {
                return Ref3L.Where(o => o.id == RefId).FirstOrDefault().yanit;
            }
            catch
            {
                Logger.Write("Reference3 Not Found, RefId = " + RefId.ToString(), "Exception");
                return Convert.ToDecimal(0);
            }
        }

        public static int GetRef3Int(int RefId)
        {
            try
            {
                int res = (int)Math.Round((decimal)Ref3L.Where(o => o.id == RefId).FirstOrDefault().yanit);
                return res;
            }
            catch
            {
                Logger.Write("Reference3 Not Found, RefId = " + RefId.ToString(), "Exception");
                return 0;
            }
        }

        #endregion

        #region Get Ref3List

        public static IList<Ref3> Ref3List()
        {
            IList<Ref3> RefList = new List<Ref3>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Ref3_All", RefList);
            return RefList;
        }

        #endregion

        #region Get Ref4

        public static string GetRef4(int RefId)
        {
            try
            {
                return Ref4L.Where(o => o.id == RefId).FirstOrDefault().yanit;
            }
            catch
            {
                Logger.Write("Reference4 Not Found, RefId = " + RefId.ToString(), "Exception");
                return null;
            }
        }

        #endregion

        #region Get Ref4List

        public static IList<Ref4> Ref4List()
        {
            IList<Ref4> RefList = new List<Ref4>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Ref4_All", RefList);
            return RefList;
        }

        #endregion

        #region Get Ref5

        public static string GetRef5(int RefId)
        {
            try
            {
                return Ref5L.Where(o => o.id == RefId).FirstOrDefault().yanit.Replace("{ImageUrl}", Parameters.WebSiteImageUrl).Replace("{Year}", DateTime.Now.Year.ToString()).Replace("{Date}", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")).Replace("{SiteUrl}", Parameters.WebSiteUrl).Replace("{SiteTitle}", Parameters.WebSiteTitle).Trim();
            }
            catch
            {
                Logger.Write("Reference 5 Not Found, RefId = " + RefId.ToString(), "Exception");
                return null;
            }
        }

        #endregion

        #region Get Ref5List

        public static IList<Ref5> Ref5List()
        {
            IList<Ref5> RefList = new List<Ref5>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Ref5_All", RefList);
            return RefList;
        }

        #endregion

        #region old

        #region Get Ref1Old

        public static string GetRef1Old(int RefId)
        {
            string ret = (string)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Ref1_Get", new object[] { RefId });
            if (ret == null)
            {
                Logger.Write("Reference1 Not Found, RefId = " + RefId.ToString(), "Exception");
            }

            return ret;
        }

        #endregion

        #region Get Ref2Old

        public static DateTime GetRef2Old(int RefId)
        {
            DateTime ret = (DateTime)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Ref2_Get", new object[] { RefId });
            if (ret == null)
            {
                Logger.Write("Reference2 Not Found, RefId = " + RefId.ToString(), "Exception");
            }

            return ret;
        }

        #endregion

        #region Get Ref3Old

        public static decimal GetRef3Old(int RefId)
        {
            decimal? ret = (decimal?)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Ref3_Get", new object[] { RefId });
            if (!ret.HasValue)
            {
                Logger.Write("Reference3 Not Found, RefId = " + RefId.ToString(), "Exception");
                ret = 0;
            }

            return (decimal)ret;
        }

        public static int GetRef3IntOld(int RefId)
        {
            decimal? ret = (decimal?)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Ref3_Get", new object[] { RefId });
            if (!ret.HasValue)
            {
                Logger.Write("Reference3 Not Found, RefId = " + RefId.ToString(), "Exception");
                ret = 0;
            }
            int res = (int)Math.Round((decimal)ret);

            return res;
        }

        #endregion

        #region Get Ref4Old

        public static string GetRef4Old(int RefId)
        {
            string ret = (string)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Ref4_Get", new object[] { RefId });
            if (ret == null)
            {
                Logger.Write("Reference4 Not Found, RefId = " + RefId.ToString(), "Exception");
            }

            return ret;
        }

        #endregion

        #region Get Ref5Old

        public static string GetRef5Old(int RefId)
        {
            string ret = (string)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Ref5_Get", new object[] { RefId });
            if (ret == null)
            {
                Logger.Write("Reference5 Not Found, RefId = " + RefId.ToString(), "Exception");
                ret = "";
            }

            ret = ret.Replace("{ImageUrl}", Parameters.WebSiteImageUrl);

            return ret.Trim();
        }

        #endregion

        #endregion

        #region declare RefLists

        static IList<Ref1> Ref1L;
        static IList<Ref2> Ref2L;
        static IList<Ref3> Ref3L;
        static IList<Ref4> Ref4L;
        static IList<Ref5> Ref5L;

        #endregion

        #region Refresh Web Site Parameters

        public static bool RefreshSiteParameters()
        {
            try
            {
                Ref1L = dbRefs.Ref1List();
                Ref2L = dbRefs.Ref2List();
                Ref3L = dbRefs.Ref3List();
                Ref4L = dbRefs.Ref4List();
                Ref5L = dbRefs.Ref5List();

                #region WebSiteImageUrl & WebSiteUrl & WebSiteSecureUrl

                Parameters.WebSiteImageUrl = dbRefs.GetRef1(1909);

                Parameters.WebSiteUrl = dbRefs.GetRef1(1912);

                if (Parameters.WebSiteUrl.IndexOf("http") < 0)
                {
                    Parameters.WebSiteUrl = "http://" + Parameters.WebSiteUrl;
                }

                //sec
                if (dbRefs.GetRef1(1913) == "E")
                {
                    Parameters.WebSiteSecureUrl = Parameters.WebSiteUrl.Replace("http://", "https://");
                }
                else
                {
                    Parameters.WebSiteSecureUrl = "";
                }
                Parameters.HttpsEnabled = dbRefs.GetRef1(1913) == "E";

                Parameters.AllowVisitorsToUsingCart = dbRefs.GetRef1(1914) == "E";
                Parameters.UseCaptchaOnRegister = dbRefs.GetRef1(3100) == "E";
                Parameters.CheckOutPageUseCardAnimation = dbRefs.GetRef1(3200) == "E";
                Parameters.CheckOutPageUseCardAnimation = dbRefs.GetRef1(3201) == "E";
                Parameters.CheckOutTCKNRequired = dbRefs.GetRef1(3201) == "E";

                Parameters.WebSiteScriptUrl = dbRefs.GetRef1(1907);

                #endregion

                #region Cache All Ref5 Pages and Content

                dbPage.GetListAll(Parameters.WebSiteImageUrl);

                #endregion

                Parameters.DefaultCulture = dbRefs.GetRef1(2150);
                Parameters.Theme = dbRefs.GetRef1(2151);
                Parameters.Layout = dbRefs.GetRef1(2152);
                Parameters.WebSiteTitle = dbRefs.GetRef1(1899);

                Parameters.InstallmentInfo = dbRefs.GetRef1(2012);
                Parameters.ProductCargoPhrase = dbRefs.GetRef1(2013);
                Parameters.ProductFastCargoPhrase = dbRefs.GetRef1(2032);
                Parameters.ProductShowFastCargoInHtml = dbRefs.GetRef1(2033) == "E" ? true : false;
                Parameters.ProductShowFreeCargoInHtml = dbRefs.GetRef1(2034) == "E" ? true : false;
                Parameters.ProductShowTabsOverExtraFields = dbRefs.GetRef1(2035) == "E" ? true : false;

                Parameters.TaxIncludedPhrase = dbRefs.GetRef1(2014);

                Parameters.AdditionFeeForPaymentAtDoor = dbRefs.GetRef3(2017);
                Parameters.CargoLimit = dbRefs.GetRef3(2015);

                Parameters.CargoMinLimit = dbRefs.GetRef3(2031);
                Parameters.CargoMinLimitPrice = dbRefs.GetRef3(2032);
                Parameters.OnlyOneCargoPrice = dbRefs.GetRef3(2033);
                Parameters.FreeCargoDesiLimit = dbRefs.GetRef3(2034);
                Parameters.DefaultDesi = dbRefs.GetRef3(2080);
                Parameters.DefaultTaxRate = dbRefs.GetRef3(1510);

                #region CreditCardDiscount & TransferDiscount

                Parameters.CreditCardDiscount = 1 + (dbRefs.GetRef3(2012) / 100);   // Ör: 1 geliyor 1.01 yapıyoruz

                Parameters.UseTransferDiscount = dbRefs.GetRef3(2010) == 1 ? true : false;
                if (Parameters.UseTransferDiscount)
                {
                    Parameters.TransferDiscount = 1 - (dbRefs.GetRef3(2011) / 100);     // Ör: 1 geliyor 0.99 yapıyoruz
                }
                else
                {
                    Parameters.TransferDiscount = 1;
                }

                #endregion

                Parameters.DefaultPosId = dbRefs.GetRef3Int(2016); // Tek Çekim Default Pos
                Parameters.UseSelfPosOneInstallment = dbRefs.GetRef1(3020).ToUpperInvariant() == "E" ? true : false;
                Parameters.DefaultCargoCompanyId = (short)dbRefs.GetRef3Int(2014);
                Parameters.DefaultExchangeType = (short)dbRefs.GetRef3Int(1400);

                Parameters.DefaultPosIdCustom = dbRefs.GetRef3Int(2027); // Tek Çekim Default Pos

                Parameters.AnindaKrediMaxTaksit = dbRefs.GetRef3Int(1300);
                Parameters.SenetMaxTaksit = dbRefs.GetRef3Int(1301);
                Parameters.SenetEkUcret = dbRefs.GetRef3Int(1302);
                Parameters.SenetTaksit1 = dbRefs.GetRef3Int(1303);
                Parameters.SenetTaksit2 = dbRefs.GetRef3Int(1304);
                Parameters.AnindaKrediTaksit1 = dbRefs.GetRef3Int(1305);


                Parameters.UseVoucher = dbRefs.GetRef3(2020) == 1 ? true : false;
                Parameters.UsePartialPayment = dbRefs.GetRef3(2030) == 1 ? true : false;
                Parameters.UseWishList = dbRefs.GetRef3(2040) == 1 ? true : false;

                Parameters.VoucherMinLimit = dbRefs.GetRef3(2021);
                Parameters.VoucherPercent = (int)dbRefs.GetRef3(2022);

                Parameters.FaceBookAppId = dbRefs.GetRef1(2120);
                Parameters.TwitterAppId = dbRefs.GetRef1(2122);

                #region ListCargoProduct & Tax

                try
                {
                    Parameters.ListCargoProductId = dbRefs.GetRef3Int(2041);

                    Product ListCargoProduct = dbProduct.Get(Parameters.ListCargoProductId, 0);

                    Parameters.ListCargoProductTax = (1 + (ListCargoProduct != null ? ListCargoProduct.TaxRate : 18 / 100));
                    ListCargoProduct = null;
                }
                catch (Exception ex)
                {
                    Logger.Write("Reading WishList Cargo Product and Tax (Check #2041 ref and related product) ->" + ex.Message, "Exception");
                }

                #endregion

                #region Page Parts

                Parameters.HeaderMessage = dbRefs.GetRef1(1903);
                Parameters.PageMainMenu = dbPage.Get(79);
                Parameters.PageMainMenuMobil = dbPage.Get(84);
                Parameters.PageInformation = dbPage.Get(80);
                Parameters.PageFooter = dbPage.Get(81);
                Parameters.PageTopMenu = dbPage.Get(82);
                Parameters.PageLoginMenu = dbPage.Get(83);

                #endregion

                #region Category IDs

                Parameters.MainCategoryId = dbRefs.GetRef3Int(2050);
                Parameters.BrandCategoryId = dbRefs.GetRef3Int(2051);
                Parameters.PageGroupsCategoryId = dbRefs.GetRef3Int(2052);
                Parameters.HomePageCategoryId = dbRefs.GetRef3Int(2053);
                Parameters.BestSellingCategoryId = dbRefs.GetRef3Int(2054);
                Parameters.OurSuggestionsCategoryId = dbRefs.GetRef3Int(2056);
                Parameters.AdditionMenuCategoryId = dbRefs.GetRef3Int(2057);
                Parameters.HomePageTabCategoryId = dbRefs.GetRef3Int(2058);
                Parameters.DailyOffersCategoryId = dbRefs.GetRef3Int(2059);

                #endregion

                #region Google Analytics

                Parameters.WebSiteTrackingCode = dbRefs.GetRef1(1920);
                Parameters.WebSiteTrackingDomainName = dbRefs.GetRef1(1921);
                Parameters.AdWordsConversionId = dbRefs.GetRef1(1922);

                #endregion

                #region MSN

                Parameters.MsnClientID = dbRefs.GetRef1(2118);
                Parameters.MsnSecretKey = dbRefs.GetRef1(2119);

                #endregion

                #region Email

                Parameters.EMail.Smtp = dbRefs.GetRef1(2100);
                Parameters.EMail.Port = dbRefs.GetRef1(2101);
                Parameters.EMail.UserName = dbRefs.GetRef1(2102);
                Parameters.EMail.Password = dbRefs.GetRef1(2103);
                Parameters.EMail.FromName = dbRefs.GetRef1(2104);
                Parameters.EMail.FromEmail = dbRefs.GetRef1(2105);
                Parameters.ErrorMessageToAddress = dbRefs.GetRef1(2108);
                Parameters.XmlImportMessagesToAddress = dbRefs.GetRef1(2109);
                Parameters.OrderMailBccAddress = dbRefs.GetRef1(2112);
                Parameters.NewMemberMailBccAddress = dbRefs.GetRef1(2114);
                Parameters.SmtpSSLRequired = dbRefs.GetRef1(2099).ToUpperInvariant() == "E" ? true : false;

                #endregion

                Parameters.OnlyUseCCandMTforOpportunityProduct = dbRefs.GetRef1(3506).ToUpperInvariant() == "E" ? true : false;

                #region Product & Image Dimentions

                Parameters.ProductWidthBig = (int)dbRefs.GetRef3(1910);
                Parameters.ProductHeightBig = (int)dbRefs.GetRef3(1911);
                Parameters.ProductWideWidthBig = (int)dbRefs.GetRef3(1932);
                Parameters.ProductWideHeightBig = (int)dbRefs.GetRef3(1933);
                Parameters.ProductTallWidthBig = (int)dbRefs.GetRef3(1934);
                Parameters.ProductTallHeightBig = (int)dbRefs.GetRef3(1935);
                Parameters.ProductSquareSizeBig = (int)dbRefs.GetRef3(1936);

                Parameters.ProductWidthLarge = (int)dbRefs.GetRef3(1912);
                Parameters.ProductHeightLarge = (int)dbRefs.GetRef3(1913);
                Parameters.ProductWideWidthLarge = (int)dbRefs.GetRef3(1937);
                Parameters.ProductWideHeightLarge = (int)dbRefs.GetRef3(1938);
                Parameters.ProductTallWidthLarge = (int)dbRefs.GetRef3(1939);
                Parameters.ProductTallHeightLarge = (int)dbRefs.GetRef3(1940);
                Parameters.ProductSquareSizeLarge = (int)dbRefs.GetRef3(1941);

                Parameters.ProductWidthMiddle = (int)dbRefs.GetRef3(1914);
                Parameters.ProductHeightMiddle = (int)dbRefs.GetRef3(1915);
                Parameters.ProductWideWidthMiddle = (int)dbRefs.GetRef3(1942);
                Parameters.ProductWideHeightMiddle = (int)dbRefs.GetRef3(1943);
                Parameters.ProductTallWidthMiddle = (int)dbRefs.GetRef3(1944);
                Parameters.ProductTallHeightMiddle = (int)dbRefs.GetRef3(1945);
                Parameters.ProductSquareSizeMiddle = (int)dbRefs.GetRef3(1946);

                Parameters.ProductWidthSmall = (int)dbRefs.GetRef3(1916);
                Parameters.ProductHeightSmall = (int)dbRefs.GetRef3(1917);
                Parameters.ProductWideWidthSmall = (int)dbRefs.GetRef3(1947);
                Parameters.ProductWideHeightSmall = (int)dbRefs.GetRef3(1948);
                Parameters.ProductTallWidthSmall = (int)dbRefs.GetRef3(1949);
                Parameters.ProductTallHeightSmall = (int)dbRefs.GetRef3(1950);
                Parameters.ProductSquareSizeSmall = (int)dbRefs.GetRef3(1951);

                Parameters.CargoImageWidth = (int)dbRefs.GetRef3(1924);
                Parameters.CargoImageHeight = (int)dbRefs.GetRef3(1925);

                Parameters.PosImageWidth = (int)dbRefs.GetRef3(1926);
                Parameters.PosImageHeight = (int)dbRefs.GetRef3(1927);

                Parameters.CategoryWidth = (int)dbRefs.GetRef3(1922);
                Parameters.CategoryHeight = (int)dbRefs.GetRef3(1923);

                Parameters.ProductDetailShowCargoPrice = dbRefs.GetRef1(2001).ToUpperInvariant() == "E" ? true : false;
                Parameters.CargoCalculateForSameProduct = dbRefs.GetRef1(2002).ToUpperInvariant() == "E" ? true : false;

                #endregion

                #region Azure Storage

                Parameters.StorageAccount = dbRefs.GetRef1(2154);
                Parameters.StorageURL = dbRefs.GetRef1(2153);
                Parameters.StoragePrimaryKey = dbRefs.GetRef1(2155);
                Parameters.StorageSecondaryKey = dbRefs.GetRef1(2156);
                Parameters.StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=" + Parameters.StorageAccount + ";AccountKey=" + Parameters.StoragePrimaryKey;

                #endregion

                #region Cities & FreeCargoCities

                Parameters.CityList = dbCity.GetAll();

                try
                {
                    IList<CityDDL> Cities = dbCity.GetFreeCargoCities();
                    Parameters.FreeCargoCities = new List<short>();
                    if (Cities != null && Cities.Count > 0)
                    {
                        string citiesDiv = "";
                        foreach (CityDDL city in Cities)
                        {
                            //citiesDiv = citiesDiv + "<tr><td>" + city.CityName + "</td></tr>";
                            if (city.ShowFreeInCity)
                            {
                                citiesDiv = citiesDiv + "<li>" + city.CityName + "</li>";
                            }
                            Parameters.FreeCargoCities.Add(city.CityId);
                        }
                        //Parameters.FreeCitiesHtml = "<div class='freeCities'><table><thead><tr><td>Şehirler</td></tr></thead><tbody>" + citiesDiv + "</tbody></table></div>";
                        Parameters.FreeCitiesHtml = "<div class='freeCities'><ul>" + citiesDiv + "</ul></div>";
                    }
                    else
                    {
                        Parameters.FreeCitiesHtml = "";
                        Cities = new List<CityDDL>();
                    }
                }
                catch
                {
                    Logger.Write("Ücretsiz Kargo ve Kurulum Yapılan İller Okunurken Hata Oluştu, Herhangi Bir Şehir Seçilmedi", "Exception");
                    Parameters.FreeCargoCities = new List<short>();
                }

                Parameters.RegionList = dbCity.GetRegions();

                #endregion

                #region Transfer/EFT bank List

                Parameters.BankList = dbBank.GetList();
                if (Parameters.BankList == null)
                {
                    Parameters.BankList = new List<Bank>();
                }

                #endregion

                #region CargoList

                Parameters.CargoList = dbCargo.GetList();
                if (Parameters.CargoList == null)
                {
                    Parameters.CargoList = new List<Cargo>();
                    Logger.Write("Aktif Kargo Firması Bulunamadı!", "Exception");
                }

                #endregion

                Parameters.SiteMetaDescription = dbRefs.GetRef1(1450);

                Parameters.LiveChatScript = dbRefs.GetRef5(1);

                Parameters.MaxProductCountForShowcaseProducts = (int)dbRefs.GetRef3(2042);
                Parameters.MaxProductCountForSuggestedProducts = (int)dbRefs.GetRef3(2043);
                Parameters.MaxProductCountForRelatedProducts = (int)dbRefs.GetRef3(2044);
                Parameters.MaxProductCountForPage = (int)dbRefs.GetRef3(2045);
                Parameters.MaxProductCountForHomePage = (int)dbRefs.GetRef3(2046);
                Parameters.MaxProductCountForCatPage = (int)dbRefs.GetRef3(2047);
                Parameters.MaxProductCountForBestSellerPage = (int)dbRefs.GetRef3(2048);
                Parameters.CategoryListColumnCount = (int)dbRefs.GetRef3(2049);
                Parameters.BrandListColumnCount = (int)dbRefs.GetRef3(2061);

                Parameters.CampaignsPageCampaignsColumnCount = (int)dbRefs.GetRef3(2062);
                Parameters.CampaignsPageGiftsColumnCount = (int)dbRefs.GetRef3(2063);
                Parameters.CampaignsPageDiscountsColumnCount = (int)dbRefs.GetRef3(2064);



                Parameters.IsPaginationActive = dbRefs.GetRef1(2190).ToUpperInvariant().Trim() == "E" ? true : false;

                Parameters.ParameterLastUpdateDate = dbRefs.GetRef2(1100);
                Parameters.ParameterCheckInterval = (int)dbRefs.GetRef3(1905);

                Parameters.ProductDetailShowSingleImage = dbRefs.GetRef1(2000).ToUpperInvariant().Trim() == "E" ? true : false;

                Parameters.PosList = dbPos.GetList();
                foreach (Pos pos in Parameters.PosList)
                {
                    pos.PosInstallment = dbPos.GetInstallmentList(pos.PosId, 1, 1, 0, 0);
                }
                Parameters.PosListDDL = dbPos.GetListDDL();

                Parameters.BinList = dbPos.GetBinList();

                Parameters.Use3DPayment = dbRefs.GetRef1(2015) == "E" ? true : false;
                Parameters.Force3DPaymentPriceMinLimit = dbRefs.GetRef3(2019);
                Parameters.XmlExportDefaultPosForInstallment = dbRefs.GetRef3Int(2018);
                Parameters.XmlExportDefaultDeliveryTime = dbRefs.GetRef3Int(3100);
                Parameters.XmlExportDefaultDeliveryTimeInStock = dbRefs.GetRef3Int(3101);
                Parameters.ServerTimeDifference = dbRefs.GetRef3Int(1904);

                Parameters.ProductTabsWithNewTab = dbProductTab.GetList(true);
                Parameters.ProductTabsWithoutNewTab = dbProductTab.GetList(false);
                if (Parameters.ProductTabsWithNewTab == null) { Parameters.ProductTabsWithNewTab = new List<ProductTab>(); }
                if (Parameters.ProductTabsWithoutNewTab == null) { Parameters.ProductTabsWithoutNewTab = new List<ProductTab>(); }

                Parameters.ProductPageDescriptionSmall = dbRefs.GetRef5(350);
                Parameters.ProductPageDescriptionWide = dbRefs.GetRef5(351);
                Parameters.ProductPageDefaultDescription = dbRefs.GetRef5(352);
                Parameters.MinInStockAmountForFastCargo = dbRefs.GetRef3(2025);
                Parameters.MinDeliveryTimeForFastCargo = dbRefs.GetRef3(2026);

                Parameters.CriticalStockAlertAmount = (int)dbRefs.GetRef3(1540);

                Parameters.AddThisShareButtonsProductPageScript = dbRefs.GetRef5(400);
                Parameters.AddThisShareButtonsSmartLayerScript = dbRefs.GetRef5(401);

                Parameters.OrderCompleteTraceScript = dbRefs.GetRef5(600);
                Parameters.CartTraceScript = dbRefs.GetRef5(601);
                Parameters.RegisterTraceScript = dbRefs.GetRef5(602);

                Parameters.HeaderSocialButtons = dbRefs.GetRef5(420);

                Parameters.CartHeadText = dbRefs.GetRef5(440);
                Parameters.CheckOutHeadText = dbRefs.GetRef5(441);

                Parameters.HomeLightboxOnReady = dbRefs.GetRef5(500);
                Parameters.HomeLightboxOnReadyName = dbRefs.GetRef1(2300);
                Parameters.HomeLightboxOnReadyExpireDayCount = (int)dbRefs.GetRef3(2300);


                Parameters.PageLeftInstallmentAndReturn = dbRefs.GetRef5(510);
                Parameters.CampaignsPageBannerImage = dbRefs.GetRef5(511);

                Parameters.PrimaryPhoneNumber = dbRefs.GetRef1(2350);
                Parameters.BankAccountName = dbRefs.GetRef1(2360);

                Parameters.Error404NotFound = dbRefs.GetRef5(404);
                Parameters.RejoinerTrackingMemberPageScript = dbRefs.GetRef5(405);
                Parameters.RejoinerTrackingPaymentOkPageScript = dbRefs.GetRef5(406);

                Parameters.UsePromoCode = dbRefs.GetRef1(2020).ToUpperInvariant() == "E" ? true : false;

                Parameters.AllowEndedProducts = dbRefs.GetRef1(1517).ToUpperInvariant() == "E" ? true : false;

                Parameters.UcuzuWebAPIKey = dbRefs.GetRef1(2170);
                Parameters.UcuzuTrusterdShopEnabled = dbRefs.GetRef1(2171).ToUpperInvariant() == "E" ? true : false;

                Parameters.GittiGidiyorAPIKey = dbRefs.GetRef1(2180);
                Parameters.GittiGidiyorSecretKey = dbRefs.GetRef1(2181);
                Parameters.GittiGidiyorRoleName = dbRefs.GetRef1(2182);
                Parameters.GittiGidiyorRolePass = dbRefs.GetRef1(2183);

                Parameters.HomePageLeftBanner = dbRefs.GetRef5(95);
                Parameters.HomePageUnderBannerCats = dbRefs.GetRef5(96);
                Parameters.HomePageUnderBanner = dbRefs.GetRef5(97);
                Parameters.HomePageSideBanner = dbRefs.GetRef5(98);
                Parameters.AddToCartButton = dbRefs.GetRef5(99);
                Parameters.LedPanelText = dbRefs.GetRef5(501);

                Parameters.VoucherPaymentDescription = dbRefs.GetRef5(550);
                Parameters.QuickCreditPaymentDescription = dbRefs.GetRef5(551);

                Parameters.ProductDefaultQuestionText = dbRefs.GetRef1(2040);

                Parameters.ShowBrandFilter = dbRefs.GetRef1(2029).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowBrandSelection = dbRefs.GetRef1(2021).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowSubCategories = dbRefs.GetRef1(2030).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowVariantsAsRadio = dbRefs.GetRef1(2031).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowPricesWithoutTax = dbRefs.GetRef1(2022).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowExchangePricesWithoutTax = dbRefs.GetRef1(2023).ToUpperInvariant() == "E" ? true : false;
                Parameters.SetPricesWithoutTax = dbRefs.GetRef3(1219) == 2 ? true : false;
                Parameters.SetCargoPricesWithoutTax = dbRefs.GetRef3(1221) == 2 ? true : false;
                Parameters.ShowFBLikeboxOnHome = dbRefs.GetRef1(2024).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowOrderOptionsAsDropdown = dbRefs.GetRef1(2025).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowPaginationAsDropdown = false; // dbRefs.GetRef1(2026).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowPriceRangeAsCheckbox = dbRefs.GetRef1(2027).ToUpperInvariant() == "E" ? true : false;
                Parameters.HideOddFromPrice = dbRefs.GetRef1(2028).ToUpperInvariant() == "E" ? true : false;

                Parameters.UsePaymentAtDoor = dbRefs.GetRef1(2016).ToUpperInvariant() == "E" ? true : false;
                Parameters.UsePaymentQuickCredit = dbRefs.GetRef1(3000).ToUpperInvariant() == "E" ? true : false;
                Parameters.UsePaymentBond = dbRefs.GetRef1(3001).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowVoucherPricesWithInstallment = dbRefs.GetRef1(3002).ToUpperInvariant() == "E" ? true : false;
                Parameters.OnlyVoucherPriceOnCampaignsPage = dbRefs.GetRef1(3003).ToUpperInvariant() == "E" ? true : false;


                Parameters.DeliveryMailAddress = dbRefs.GetRef1(3050);
                Parameters.CustomCheckOutMailAddress = dbRefs.GetRef1(2115);
                Parameters.CareerFormMailAddress = dbRefs.GetRef1(2116);

                Parameters.ContactManagementDepartmentAddress = dbRefs.GetRef1(2124);
                Parameters.ContactAccountingDepartmentAddress = dbRefs.GetRef1(2125);
                Parameters.ContactSalesDepartmentAddress = dbRefs.GetRef1(2126);
                Parameters.ContactCustomerSatisfactiontDepartmentAddress = dbRefs.GetRef1(2127);
                Parameters.ContactBCCAddress = dbRefs.GetRef1(2128);

                Parameters.FaceBookCommentCode = dbRefs.GetRef5(410);
                Parameters.FaceBookLikebox = dbRefs.GetRef5(411);

                Parameters.UseCategoryHeader = dbRefs.GetRef1(2017).ToUpperInvariant() == "E" ? true : false;
                Parameters.UseTabsInProductDetail = dbRefs.GetRef1(2019).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowTopSellersOnHomePage = dbRefs.GetRef1(2018).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowCategoryOnAccountPages = dbRefs.GetRef1(2011).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowCategoryOnContentPages = dbRefs.GetRef1(2010).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowCategoryOnProductsPages = dbRefs.GetRef1(2009).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowCategoryOnCategoryPages = dbRefs.GetRef1(2008).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowCategoryOnProductPages = dbRefs.GetRef1(2007).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowCategoryOnOrderPages = dbRefs.GetRef1(2006).ToUpperInvariant() == "E" ? true : false;
                Parameters.ShowTopSellersOnProductPage = dbRefs.GetRef1(1999).ToUpperInvariant() == "E" ? true : false;

                Parameters.PageDescription = dbRefs.GetRef1(1896);

                Parameters.ProductViewSliderType = (int)dbRefs.GetRef3(2070);
                Parameters.HomePageSliderType = (int)dbRefs.GetRef3(2071);
                Parameters.HomePageSliderMaxImageCount = (int)dbRefs.GetRef3(2072);

                Parameters.DeliveryContract = dbRefs.GetRef5(21);
                Parameters.CustomCheckOutAgreement = dbRefs.GetRef5(31);

                Parameters.ProductUrlFolderName = "urun";

                Parameters.PayuSignatureKey = dbRefs.GetRef1(4000);
                Parameters.PayuEnvironment = dbRefs.GetRef1(4001);
                Parameters.PayuMerchantId = dbRefs.GetRef1(4002);

                Parameters.AmbarList = dbReportPanel.AmbarListesi();


                //test--

                return true;
            }
            catch (Exception ex)
            {
                Logger.Write(ex, "Exception");
                return false;
            }
        }

        #endregion
    }
}
